﻿<!-- Views/Admin/EditUser.cshtml -->
@model WebApplication1.Models.User

@{
    ViewBag.Title = "编辑用户";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container">
    <h2>编辑用户</h2>
    <hr />

    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()
        @Html.HiddenFor(model => model.UserId)

        <div class="form-horizontal">
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })

            <div class="form-group">
                @Html.LabelFor(model => model.Username, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Username, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Username, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.FullName, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.FullName, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.FullName, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control", type = "password", placeholder = "留空则不更改密码" } })
                    @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.Label("ConfirmPassword", "确认密码", htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.Editor("ConfirmPassword", new { htmlAttributes = new { @class = "form-control", type = "password" } })
                    <span class="help-block">如果要更改密码，请输入新密码并确认</span>
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Role, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownListFor(model => model.Role, new SelectList(new List<SelectListItem>
                    {
                        new SelectListItem { Text = "管理员", Value = "Admin" },
                        new SelectListItem { Text = "员工", Value = "Employee" }
                    }, "Value", "Text", Model.Role), new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.Role, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="保存更改" class="btn btn-primary" />
                    <a href="@Url.Action("Users", "Admin")" class="btn btn-default">取消</a>
                </div>
            </div>
        </div>
    }
</div>

@section Scripts {

}